<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="stable/static/css/site.css" rel="stylesheet" type="text/css">
    <link href="stable/static/css/print.css" rel="stylesheet" type="text/css" media="print">
    <link href="stable/static/css/prettify.css" rel="stylesheet" type="text/css">
    <link href="//www.google.com/images/icons/product/chrome-16.png" rel="icon" type="image/ico">
    <link href="stable/static/css/api.css" rel="stylesheet" type="text/css">
    <title>chrome.windows - chrome插件中文开发文档(非官方)</title>
  </head>
  <body>
    <a id="top"></a>
    <div id="header">{Header content}</div>
    <a id="gc-topnav-anchor"></a>
    <div id="gc-topnav">
      <h1>Google Chrome Extensions</h1>
      <ul id="home" class="gc-topnav-tabs">
        <li id="home_link">
          <a href="index.html" title="Google Chrome Extensions home page"><div>Home</div></a>
        </li>
        <li id="docs_link">
          <a href="docs.html" title="Official Google Chrome Extensions documentation"><div>Docs</div></a>
        </li>
        <li id="faq_link">
          <a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions"><div>FAQ</div></a>
        </li>
        <li id="samples_link">
          <a href="samples.html" title="Sample Extensions (with source code)"><div>Samples</div></a>
        </li>
        <li id="group_link">
          <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum"><div>Group</div></a>
        </li>
        <li id="so_link">
          <a href="http://stackoverflow.com/questions/tagged/google-chrome-extension" title="[google-chrome-extension] tag on Stack Overflow"><div>Questions?</div></a>
        </li>
      </ul>
    </div>
    <div id="gc-container">
      <div id="gc-sidebar">
        <ul 
            class="level1 ">
          <li class="level2">
                <a href="getstarted.html" class="level2 ">Getting Started</a>
          </li>
          <li class="level2">
                <a href="overview.html" class="level2 ">Overview</a>
          </li>
          <li class="level2">
                <a href="whats_new.html" class="level2 ">What's New?</a>
          </li>
          <li class="level2">
                <a href="devguide.html" class="level2 ">Developer's Guide</a>
              <ul 
                  class="level2 ">
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Browser UI</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="browserAction.html" class="level4 ">Browser Actions</a>
                      </li>
                      <li class="level4">
                            <a href="contextMenus.html" class="level4 ">Context Menus</a>
                      </li>
                      <li class="level4">
                            <a href="notifications.html" class="level4 ">Desktop Notifications</a>
                      </li>
                      <li class="level4">
                            <a href="omnibox.html" class="level4 ">Omnibox</a>
                      </li>
                      <li class="level4">
                            <a href="options.html" class="level4 ">Options Pages</a>
                      </li>
                      <li class="level4">
                            <a href="override.html" class="level4 ">Override Pages</a>
                      </li>
                      <li class="level4">
                            <a href="pageAction.html" class="level4 ">Page Actions</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Browser Interaction</span>
                      <div class="toggleIndicator level3 toggled"></div>
                    </a>
                    <ul toggleable
                        class="level3 ">
                      <li class="level4">
                            <a href="bookmarks.html" class="level4 ">Bookmarks</a>
                      </li>
                      <li class="level4">
                            <a href="cookies.html" class="level4 ">Cookies</a>
                      </li>
                      <li class="level4">
                            <a href="devtools.html" class="level4 ">Developer Tools</a>
                      </li>
                      <li class="level4">
                            <a href="events.html" class="level4 ">Events</a>
                      </li>
                      <li class="level4">
                            <a href="history.html" class="level4 ">History</a>
                      </li>
                      <li class="level4">
                            <a href="management.html" class="level4 ">Management</a>
                      </li>
                      <li class="level4">
                            <a href="tabs.html" class="level4 ">Tabs</a>
                      </li>
                      <li class="level4">
                            <a  class="level4 selected">Windows</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Implementation</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="a11y.html" class="level4 ">Accessibility</a>
                      </li>
                      <li class="level4">
                            <a href="event_pages.html" class="level4 ">Event Pages</a>
                      </li>
                      <li class="level4">
                            <a href="contentSecurityPolicy.html" class="level4 ">Content Security Policy</a>
                      </li>
                      <li class="level4">
                            <a href="content_scripts.html" class="level4 ">Content Scripts</a>
                      </li>
                      <li class="level4">
                            <a href="xhr.html" class="level4 ">Cross-Origin XHR</a>
                      </li>
                      <li class="level4">
                            <a href="i18n.html" class="level4 ">Internationalization</a>
                      </li>
                      <li class="level4">
                            <a href="messaging.html" class="level4 ">Message Passing</a>
                      </li>
                      <li class="level4">
                            <a href="permissions.html" class="level4 ">Optional Permissions</a>
                      </li>
                      <li class="level4">
                            <a href="npapi.html" class="level4 ">NPAPI Plugins</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Finishing</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="hosting.html" class="level4 ">Hosting</a>
                      </li>
                      <li class="level4">
                            <a href="external_extensions.html" class="level4 ">Other Deployment Options</a>
                      </li>
                    </ul>
                </li>
              </ul>
          </li>
          <li class="level2">
                <a href="tutorials.html" class="level2 ">Tutorials</a>
              <ul 
                  class="level2 ">
                <li class="level3">
                      <a href="tut_migration_to_manifest_v2.html" class="level3 ">Manifest V2</a>
                </li>
                <li class="level3">
                      <a href="tut_debugging.html" class="level3 ">Debugging</a>
                </li>
                <li class="level3">
                      <a href="tut_analytics.html" class="level3 ">Google Analytics</a>
                </li>
                <li class="level3">
                      <a href="tut_oauth.html" class="level3 ">OAuth</a>
                </li>
              </ul>
          </li>
          <li class="level2">
                <span class="level2">Reference</span>
              <ul 
                  class="level2 ">
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Formats</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="manifest.html" class="level4 ">Manifest Files</a>
                      </li>
                      <li class="level4">
                            <a href="match_patterns.html" class="level4 ">Match Patterns</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                      <a href="permission_warnings.html" class="level3 ">Permission Warnings</a>
                </li>
                <li class="level3">
                      <a href="api_index.html" class="level3 ">chrome.* APIs</a>
                </li>
                <li class="level3">
                      <a href="api_other.html" class="level3 ">Other APIs</a>
                </li>
              </ul>
          </li>
          <li class="level2">
                <span class="level2">More</span>
              <ul 
                  class="level2 ">
                <li class="level3">
                      <a href="http://code.google.com/chrome/webstore/docs/index.html" class="level3 ">Chrome Web Store</a>
                </li>
                <li class="level3">
                      <a href="http://code.google.com/chrome/apps/docs/developers_guide.html" class="level3 ">Hosted Apps</a>
                </li>
                <li class="level3">
                      <a href="themes.html" class="level3 ">Themes</a>
                </li>
              </ul>
          </li>
        </ul>
      </div>
      <div id="gc-pagecontent">
        <h1 class="page_title">chrome.windows</h1>
        
        
        
        <div id="toc">
          <h2>Contents</h2>
          <ol>
            <li>
              <a href=#manifest>Manifest</a>
            </li>
            <li>
              <a href=#current-window>The current window</a>
            </li>
            <li>
              <a href=#examples> Examples </a>
            </li>
            <li>
              <a href="#apiReference">API reference: chrome.windows</a>
              <ol>
                  <li><a href="#types">Types</a><ol>  <li>    <a href="#type-Window">Window</a>  </li></ol></li>
                  <li><a href="#properties">Properties</a><ol>  <li>    <a href="#property-WINDOW_ID_NONE">WINDOW_ID_NONE</a>  </li>  <li>    <a href="#property-WINDOW_ID_CURRENT">WINDOW_ID_CURRENT</a>  </li></ol></li>
                  <li><a href="#methods">Methods</a><ol>  <li><a href="#method-get">get</a></li>  <li><a href="#method-getCurrent">getCurrent</a></li>  <li><a href="#method-getLastFocused">getLastFocused</a></li>  <li><a href="#method-getAll">getAll</a></li>  <li><a href="#method-create">create</a></li>  <li><a href="#method-update">update</a></li>  <li><a href="#method-remove">remove</a></li></ol></li>
                  <li><a href="#events">Events</a><ol>  <li><a href="#event-onCreated">onCreated</a></li>  <li><a href="#event-onRemoved">onRemoved</a></li>  <li><a href="#event-onFocusChanged">onFocusChanged</a></li></ol></li>
                  <li><a href="#samples">Sample Extensions</a></li>
              </ol>
            </li>
          </ol>
        </div>

<p id="classSummary">
Use the <code>chrome.windows</code> module
to interact with browser windows.
You can use this module to
create, modify, and rearrange windows in the browser.
</p>

<img src="stable/static/images/windows.png"
     width="256" height="76" alt="Two windows, each with one tab" />

<h2 id="manifest">Manifest</h2>
<p>
To use the windows API,
you must declare the "tabs" permission
in <a href="manifest.html">manifest.json</a>.
(No, that isn't a typo &mdash;
the window and tabs modules interact so closely we
decided to just share one permission between them.)
For example:
</p>

<pre>{
  "name": "My extension",
  ...
  <b>"permissions": ["tabs"]</b>,
  ...
}</pre>

<h2 id="current-window">The current window</h2>

<p>Many functions in the extension system
take an optional <var>windowId</var> parameter,
which defaults to the current window.
</p>

<p>The <em>current window</em> is the window that
contains the code that is currently executing.
It's important to realize that this can be
different from the topmost or focused window.
</p>

<p>For example, say an extension
creates a few tabs or windows from a single HTML file,
and that the HTML file
contains a call to
<a href="tabs.html#method-getSelected">chrome.tabs.getSelected</a>.
The current window is the window that contains the page that made
the call, no matter what the topmost window is.
</p>

<p>In the case of the <a href="event_pages.html">event page</a>,
the value of the current window falls back to the last active window. Under some
circumstances, there may be no current window for background pages.
</p>

<h2 id="examples"> Examples </h2>

<p>
You can find simple examples of using the windows module in the
<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/windows/">examples/api/windows</a>
directory.
Another example is in the
<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/tabs/inspector/tabs_api.html?content-type=text/plain">tabs_api.html</a> file
of the
<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/tabs/inspector/">inspector</a>
example.
For other examples and for help in viewing the source code, see
<a href="samples.html">Samples</a>.
</p>
        <h2 id="apiReference">API Reference: chrome.windows</h2>
        <div class="api_reference">
            <h3 id="types">Types</h3>
              <div>
                <h3 id="type-Window">Window</h3>
                <div>
                  <dt><span class="type_name">  (    <span id="typeTemplate">object</span>  )</span></dt>
                  <h4 id="Window-properties">
                    Properties of <a href="#type-Window">Window</a>
                  </h4>
                  <dd><dl>      <div>
                      <a name="property-Window-id"></a>
                      <dt>
                        <span class="variable">id</span>
                        <span class="property">
                          (
                            
                            <span id="typeTemplate">integer</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The ID of the window. Window IDs are unique within a browser session.
                      </dd>
                    </div>
                    <div>
                      <a name="property-Window-focused"></a>
                      <dt>
                        <span class="variable">focused</span>
                        <span class="property">
                          (
                            
                            <span id="typeTemplate">boolean</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        Whether the window is currently the focused window.
                      </dd>
                    </div>
                    <div>
                      <a name="property-Window-top"></a>
                      <dt>
                        <span class="variable">top</span>
                        <span class="property">
                          (
                            
                            <span id="typeTemplate">integer</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The offset of the window from the top edge of the screen in pixels.
                      </dd>
                    </div>
                    <div>
                      <a name="property-Window-left"></a>
                      <dt>
                        <span class="variable">left</span>
                        <span class="property">
                          (
                            
                            <span id="typeTemplate">integer</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The offset of the window from the left edge of the screen in pixels.
                      </dd>
                    </div>
                    <div>
                      <a name="property-Window-width"></a>
                      <dt>
                        <span class="variable">width</span>
                        <span class="property">
                          (
                            
                            <span id="typeTemplate">integer</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The width of the window in pixels.
                      </dd>
                    </div>
                    <div>
                      <a name="property-Window-height"></a>
                      <dt>
                        <span class="variable">height</span>
                        <span class="property">
                          (
                            
                            <span id="typeTemplate">integer</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The height of the window in pixels.
                      </dd>
                    </div>
                    <div>
                      <a name="property-Window-tabs"></a>
                      <dt>
                        <span class="variable">tabs</span>
                        <span class="property">
                          (
                            <span class="optional">optional</span>
                            <span id="typeTemplate">array of <a href="tabs.html#type-Tab">tabs.Tab</a></span>
                          )
                        </span>
                      </dt>
                      <dd>
                        Array of <a href="tabs.html#type-Tab">tabs.Tab</a> objects representing the current tabs in the window.
                      </dd>
                    </div>
                    <div>
                      <a name="property-Window-incognito"></a>
                      <dt>
                        <span class="variable">incognito</span>
                        <span class="property">
                          (
                            
                            <span id="typeTemplate">boolean</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        Whether the window is incognito.
                      </dd>
                    </div>
                    <div>
                      <a name="property-Window-type"></a>
                      <dt>
                        <span class="variable">type</span>
                        <span class="property">
                          (
                            
                            <span id="typeTemplate">enumerated string ["normal", "popup", "panel", "app"]</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The type of browser window this is.
                      </dd>
                    </div>
                    <div>
                      <a name="property-Window-state"></a>
                      <dt>
                        <span class="variable">state</span>
                        <span class="property">
                          (
                            
                            <span id="typeTemplate">enumerated string ["normal", "minimized", "maximized", "fullscreen"]</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The state of this browser window.
                      </dd>
                    </div>
                    <div>
                      <a name="property-Window-alwaysOnTop"></a>
                      <dt>
                        <span class="variable">alwaysOnTop</span>
                        <span class="property">
                          (
                            
                            <span id="typeTemplate">boolean</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        Whether the window is set to be always on top.
                      </dd>
                    </div>
              </dl></dd>
                </div>
              </div>
            <h3 id="properties">Properties</h3>
              <div>
                <h3 id="property-WINDOW_ID_NONE">WINDOW_ID_NONE</h3>
                <div class="summary">
                  <span>chrome.windows.WINDOW_ID_NONE</span>
                </div>
                <div>
                  <dt><span class="property">WINDOW_ID_NONE</span> <span class="type_name">  (    <span id="typeTemplate"><code>-1</code></span>  )</span></dt>
              <dd>
                    The windowId value that represents the absence of a chrome browser window.
                  </dd>  </div>
              </div>
              <div>
                <h3 id="property-WINDOW_ID_CURRENT">WINDOW_ID_CURRENT</h3>
                <div class="summary">
                  <span>chrome.windows.WINDOW_ID_CURRENT</span>
                </div>
                <div>
                  <dt><span class="property">WINDOW_ID_CURRENT</span> <span class="type_name">  (    <span id="typeTemplate"><code>-2</code></span>  )</span></dt>
              <dd>
                    The windowId value that represents the <a href='windows.html#current-window'>current window</a>.
                  </dd>  </div>
              </div>
            <h3 id="methods">Methods</h3>
              <div>
                <h4 id="method-get">get</h4>
                <div class="summary lower">
                  <span>chrome.windows.get</span>(<span>integer <span class="variable">windowId</span></span>, <span class="optional">object <span class="variable">getInfo</span></span>)
                </div>
                <div class="description">
              <p>
                    Gets details about a window.
                  </p>    <h4>Parameters</h4>
                  <dl>
                    <div>  <a name="property-get-windowId"></a>  <dt>    <span class="variable">windowId</span>    <span class="property">      (                <span id="typeTemplate">integer</span>      )    </span>  </dt></div><div>  <a name="property-get-getInfo"></a>  <dt>    <span class="variable">getInfo</span>    <span class="property">      (        <span class="optional">optional</span>        <span id="typeTemplate">object</span>      )    </span>  </dt>  <dd>      </dd>  <dd>    <dl>      <div>        <a name="property-getInfo-populate"></a>        <dt>          <span class="variable">populate</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span>        </dt>        <dd>          If true, the window object will have a <var>tabs</var> property that contains a list of the <a href="tabs.html#type-Tab">tabs.Tab</a> objects        </dd>      </div>    </dl>  </dd></div>
                  </dl>
                  <h4>Callback function</h4><p>      The <em>callback</em> parameter should specify a function      that looks like this:</p><pre>function(<a href="windows.html#type-Window">Window</a> window) <span class="subdued">{...}</span>;</pre><dl>  <div>  <a name="property-callback-window"></a>  <dt>    <span class="variable">window</span>    <span class="property">      (                <span id="typeTemplate"><a href="windows.html#type-Window">Window</a></span>      )    </span>  </dt></div></dl>
                </div>
              </div>
              <div>
                <h4 id="method-getCurrent">getCurrent</h4>
                <div class="summary lower">
                  <span>chrome.windows.getCurrent</span>(<span class="optional">object <span class="variable">getInfo</span></span>)
                </div>
                <div class="description">
              <p>
                    Gets the <a href='#current-window'>current window</a>.
                  </p>    <h4>Parameters</h4>
                  <dl>
                    <div>  <a name="property-getCurrent-getInfo"></a>  <dt>    <span class="variable">getInfo</span>    <span class="property">      (        <span class="optional">optional</span>        <span id="typeTemplate">object</span>      )    </span>  </dt>  <dd>      </dd>  <dd>    <dl>      <div>        <a name="property-getInfo-populate"></a>        <dt>          <span class="variable">populate</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span>        </dt>        <dd>          If true, the window object will have a <var>tabs</var> property that contains a list of the <a href="tabs.html#type-Tab">tabs.Tab</a> objects        </dd>      </div>    </dl>  </dd></div>
                  </dl>
                  <h4>Callback function</h4><p>      The <em>callback</em> parameter should specify a function      that looks like this:</p><pre>function(<a href="windows.html#type-Window">Window</a> window) <span class="subdued">{...}</span>;</pre><dl>  <div>  <a name="property-callback-window"></a>  <dt>    <span class="variable">window</span>    <span class="property">      (                <span id="typeTemplate"><a href="windows.html#type-Window">Window</a></span>      )    </span>  </dt></div></dl>
                </div>
              </div>
              <div>
                <h4 id="method-getLastFocused">getLastFocused</h4>
                <div class="summary lower">
                  <span>chrome.windows.getLastFocused</span>(<span class="optional">object <span class="variable">getInfo</span></span>)
                </div>
                <div class="description">
              <p>
                    Gets the window that was most recently focused &mdash; typically the window 'on top'.
                  </p>    <h4>Parameters</h4>
                  <dl>
                    <div>  <a name="property-getLastFocused-getInfo"></a>  <dt>    <span class="variable">getInfo</span>    <span class="property">      (        <span class="optional">optional</span>        <span id="typeTemplate">object</span>      )    </span>  </dt>  <dd>      </dd>  <dd>    <dl>      <div>        <a name="property-getInfo-populate"></a>        <dt>          <span class="variable">populate</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span>        </dt>        <dd>          If true, the window object will have a <var>tabs</var> property that contains a list of the <a href="tabs.html#type-Tab">tabs.Tab</a> objects        </dd>      </div>    </dl>  </dd></div>
                  </dl>
                  <h4>Callback function</h4><p>      The <em>callback</em> parameter should specify a function      that looks like this:</p><pre>function(<a href="windows.html#type-Window">Window</a> window) <span class="subdued">{...}</span>;</pre><dl>  <div>  <a name="property-callback-window"></a>  <dt>    <span class="variable">window</span>    <span class="property">      (                <span id="typeTemplate"><a href="windows.html#type-Window">Window</a></span>      )    </span>  </dt></div></dl>
                </div>
              </div>
              <div>
                <h4 id="method-getAll">getAll</h4>
                <div class="summary lower">
                  <span>chrome.windows.getAll</span>(<span class="optional">object <span class="variable">getInfo</span></span>)
                </div>
                <div class="description">
              <p>
                    Gets all windows.
                  </p>    <h4>Parameters</h4>
                  <dl>
                    <div>  <a name="property-getAll-getInfo"></a>  <dt>    <span class="variable">getInfo</span>    <span class="property">      (        <span class="optional">optional</span>        <span id="typeTemplate">object</span>      )    </span>  </dt>  <dd>      </dd>  <dd>    <dl>      <div>        <a name="property-getInfo-populate"></a>        <dt>          <span class="variable">populate</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span>        </dt>        <dd>          If true, each window object will have a <var>tabs</var> property that contains a list of the <a href="tabs.html#type-Tab">tabs.Tab</a> objects for that window.        </dd>      </div>    </dl>  </dd></div>
                  </dl>
                  <h4>Callback function</h4><p>      The <em>callback</em> parameter should specify a function      that looks like this:</p><pre>function(array of <a href="windows.html#type-Window">Window</a> windows) <span class="subdued">{...}</span>;</pre><dl>  <div>  <a name="property-callback-windows"></a>  <dt>    <span class="variable">windows</span>    <span class="property">      (                <span id="typeTemplate">array of <a href="windows.html#type-Window">Window</a></span>      )    </span>  </dt></div></dl>
                </div>
              </div>
              <div>
                <h4 id="method-create">create</h4>
                <div class="summary lower">
                  <span>chrome.windows.create</span>(<span class="optional">object <span class="variable">createData</span></span>)
                </div>
                <div class="description">
              <p>
                    Creates (opens) a new browser with any optional sizing, position or default URL provided.
                  </p>    <h4>Parameters</h4>
                  <dl>
                    <div>  <a name="property-create-createData"></a>  <dt>    <span class="variable">createData</span>    <span class="property">      (        <span class="optional">optional</span>        <span id="typeTemplate">object</span>      )    </span>  </dt>  <dd>    <dl>      <div>        <a name="property-createData-url"></a>        <dt>          <span class="variable">url</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">string</span>            )          </span>        </dt>        <dd>          A URL or list of URLs to open as tabs in the window. Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com', not 'www.google.com'). Relative URLs will be relative to the current page within the extension. Defaults to the New Tab Page.        </dd>      </div>      <div>        <a name="property-createData-tabId"></a>        <dt>          <span class="variable">tabId</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">integer</span>            )          </span>        </dt>        <dd>          The id of the tab for which you want to adopt to the new window.        </dd>      </div>      <div>        <a name="property-createData-left"></a>        <dt>          <span class="variable">left</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">integer</span>            )          </span>        </dt>        <dd>          The number of pixels to position the new window from the left edge of the screen. If not specified, the new window is offset naturally from the last focused window. This value is ignored for panels.        </dd>      </div>      <div>        <a name="property-createData-top"></a>        <dt>          <span class="variable">top</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">integer</span>            )          </span>        </dt>        <dd>          The number of pixels to position the new window from the top edge of the screen. If not specified, the new window is offset naturally from the last focused window. This value is ignored for panels.        </dd>      </div>      <div>        <a name="property-createData-width"></a>        <dt>          <span class="variable">width</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">integer</span>            )          </span>        </dt>        <dd>          The width in pixels of the new window. If not specified defaults to a natural width.        </dd>      </div>      <div>        <a name="property-createData-height"></a>        <dt>          <span class="variable">height</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">integer</span>            )          </span>        </dt>        <dd>          The height in pixels of the new window. If not specified defaults to a natural height.        </dd>      </div>      <div>        <a name="property-createData-focused"></a>        <dt>          <span class="variable">focused</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span>        </dt>        <dd>          If true, opens an active window. If false, opens an inactive window.        </dd>      </div>      <div>        <a name="property-createData-incognito"></a>        <dt>          <span class="variable">incognito</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span>        </dt>        <dd>          Whether the new window should be an incognito window.        </dd>      </div>      <div>        <a name="property-createData-type"></a>        <dt>          <span class="variable">type</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">enumerated string ["normal", "popup", "panel", "detached_panel"]</span>            )          </span>        </dt>        <dd>          Specifies what type of browser window to create. The 'panel' and 'detached_panel' types create a popup unless the '--enable-panels' flag is set.        </dd>      </div>    </dl>  </dd></div>
                  </dl>
                  <h4>Callback function</h4><p>      If you specify the <em>callback</em> parameter, it should      specify a function that looks like this:</p><pre>function(<a href="windows.html#type-Window">Window</a> window) <span class="subdued">{...}</span>;</pre><dl>  <div>  <a name="property-callback-window"></a>  <dt>    <span class="variable">window</span>    <span class="property">      (        <span class="optional">optional</span>        <span id="typeTemplate"><a href="windows.html#type-Window">Window</a></span>      )    </span>  </dt>  <dd>    Contains details about the created window.  </dd></div></dl>
                </div>
              </div>
              <div>
                <h4 id="method-update">update</h4>
                <div class="summary lower">
                  <span>chrome.windows.update</span>(<span>integer <span class="variable">windowId</span></span>, <span>object <span class="variable">updateInfo</span></span>)
                </div>
                <div class="description">
              <p>
                    Updates the properties of a window. Specify only the properties that you want to change; unspecified properties will be left unchanged.
                  </p>    <h4>Parameters</h4>
                  <dl>
                    <div>  <a name="property-update-windowId"></a>  <dt>    <span class="variable">windowId</span>    <span class="property">      (                <span id="typeTemplate">integer</span>      )    </span>  </dt></div><div>  <a name="property-update-updateInfo"></a>  <dt>    <span class="variable">updateInfo</span>    <span class="property">      (                <span id="typeTemplate">object</span>      )    </span>  </dt>  <dd>    <dl>      <div>        <a name="property-updateInfo-left"></a>        <dt>          <span class="variable">left</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">integer</span>            )          </span>        </dt>        <dd>          The offset from the left edge of the screen to move the window to in pixels. This value is ignored for panels.        </dd>      </div>      <div>        <a name="property-updateInfo-top"></a>        <dt>          <span class="variable">top</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">integer</span>            )          </span>        </dt>        <dd>          The offset from the top edge of the screen to move the window to in pixels. This value is ignored for panels.        </dd>      </div>      <div>        <a name="property-updateInfo-width"></a>        <dt>          <span class="variable">width</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">integer</span>            )          </span>        </dt>        <dd>          The width to resize the window to in pixels. This value is ignored for panels.        </dd>      </div>      <div>        <a name="property-updateInfo-height"></a>        <dt>          <span class="variable">height</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">integer</span>            )          </span>        </dt>        <dd>          The height to resize the window to in pixels. This value is ignored for panels.        </dd>      </div>      <div>        <a name="property-updateInfo-focused"></a>        <dt>          <span class="variable">focused</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span>        </dt>        <dd>          If true, brings the window to the front. If false, brings the next window in the z-order to the front.        </dd>      </div>      <div>        <a name="property-updateInfo-drawAttention"></a>        <dt>          <span class="variable">drawAttention</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span>        </dt>        <dd>          If true, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window. This option has no effect if the window already has focus. Set to false to cancel a previous draw attention request.        </dd>      </div>      <div>        <a name="property-updateInfo-state"></a>        <dt>          <span class="variable">state</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">enumerated string ["normal", "minimized", "maximized", "fullscreen"]</span>            )          </span>        </dt>        <dd>          The new state of the window. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'.        </dd>      </div>    </dl>  </dd></div>
                  </dl>
                  <h4>Callback function</h4><p>      If you specify the <em>callback</em> parameter, it should      specify a function that looks like this:</p><pre>function(<a href="windows.html#type-Window">Window</a> window) <span class="subdued">{...}</span>;</pre><dl>  <div>  <a name="property-callback-window"></a>  <dt>    <span class="variable">window</span>    <span class="property">      (                <span id="typeTemplate"><a href="windows.html#type-Window">Window</a></span>      )    </span>  </dt></div></dl>
                </div>
              </div>
              <div>
                <h4 id="method-remove">remove</h4>
                <div class="summary lower">
                  <span>chrome.windows.remove</span>(<span>integer <span class="variable">windowId</span></span>)
                </div>
                <div class="description">
              <p>
                    Removes (closes) a window, and all the tabs inside it.
                  </p>    <h4>Parameters</h4>
                  <dl>
                    <div>  <a name="property-remove-windowId"></a>  <dt>    <span class="variable">windowId</span>    <span class="property">      (                <span id="typeTemplate">integer</span>      )    </span>  </dt></div>
                  </dl>
                  <h4>Callback function</h4><p>      If you specify the <em>callback</em> parameter, it should      specify a function that looks like this:</p><pre>function() <span class="subdued">{...}</span>;</pre><dl>  </dl>
                </div>
              </div>
            <h3 id="events">Events</h3>
              <div>
                <h4 id="event-onCreated">onCreated</h4>
                <div class="summary">
                  <span class="subdued">chrome.windows.</span>onCreated<span class="subdued">.addListener</span>(function(<span><a href="windows.html#type-Window">Window</a> <span class="variable">window</span></span>)<span class="subdued"> {...}</span>);
                </div>
                <div class="description">
              <p>
                    Fired when a window is created.
                  </p>      <h4>Listener Parameters</h4>
                    <dl>
                      <div>  <a name="property-onCreated-window"></a>  <dt>    <span class="variable">window</span>    <span class="property">      (                <span id="typeTemplate"><a href="windows.html#type-Window">Window</a></span>      )    </span>  </dt>  <dd>    Details of the window that was created.  </dd></div>
                    </dl>
                </div>
              </div>
              <div>
                <h4 id="event-onRemoved">onRemoved</h4>
                <div class="summary">
                  <span class="subdued">chrome.windows.</span>onRemoved<span class="subdued">.addListener</span>(function(<span>integer <span class="variable">windowId</span></span>)<span class="subdued"> {...}</span>);
                </div>
                <div class="description">
              <p>
                    Fired when a window is removed (closed).
                  </p>      <h4>Listener Parameters</h4>
                    <dl>
                      <div>  <a name="property-onRemoved-windowId"></a>  <dt>    <span class="variable">windowId</span>    <span class="property">      (                <span id="typeTemplate">integer</span>      )    </span>  </dt>  <dd>    ID of the removed window.  </dd></div>
                    </dl>
                </div>
              </div>
              <div>
                <h4 id="event-onFocusChanged">onFocusChanged</h4>
                <div class="summary">
                  <span class="subdued">chrome.windows.</span>onFocusChanged<span class="subdued">.addListener</span>(function(<span>integer <span class="variable">windowId</span></span>)<span class="subdued"> {...}</span>);
                </div>
                <div class="description">
              <p>
                    Fired when the currently focused window changes. Will be chrome.windows.WINDOW_ID_NONE if all chrome windows have lost focus. Note: On some Linux window managers, WINDOW_ID_NONE will always be sent immediately preceding a switch from one chrome window to another.
                  </p>      <h4>Listener Parameters</h4>
                    <dl>
                      <div>  <a name="property-onFocusChanged-windowId"></a>  <dt>    <span class="variable">windowId</span>    <span class="property">      (                <span id="typeTemplate">integer</span>      )    </span>  </dt>  <dd>    ID of the newly focused window.  </dd></div>
                    </dl>
                </div>
              </div>
        </div>
          <h2 id="samples">Sample Extensions that use chrome.windows</h2>
            <li><strong><a href="samples.html#2b0f7d02f3ebd51358ed54ef59dceebb">Cookie API Test Extension</a></strong> &ndash;
            Testing Cookie API
        </li>
            <li><strong><a href="samples.html#f447d4d0c667a4f72ef8c6190e7925d7">Live HTTP headers</a></strong> &ndash;
            Displays the live log with the http requests headers
        </li>
            <li><strong><a href="samples.html#812b7fe611113aedf0a394e9fbbfcce1">JavaScript pause/resume</a></strong> &ndash;
            Pauses / resumes JavaScript execution
        </li>
            <li><strong><a href="samples.html#31e082ed1a598b3d1ae28197fa2a89bc">Download Selected Links</a></strong> &ndash;
            Select links on a page and download them.
        </li>
            <li><strong><a href="samples.html#5cd19f5329cf45fd555d2f754abfc5f1">Show Tabs in Process</a></strong> &ndash;
            Adds a browser action showing which tabs share the current tab's process.
        </li>
            <li><strong><a href="samples.html#062d24295dce5def19f91da9c449e1e4">Tab Inspector</a></strong> &ndash;
            Utility for working with the extension tabs api
        </li>
            <li><strong><a href="samples.html#ada4d65f29289c46d04a1920af682232">Console TTS Engine</a></strong> &ndash;
            A "silent" TTS engine that prints text to a small window rather than synthesizing speech.
        </li>
            <li><strong><a href="samples.html#f92d20e2d53aae42280f27e7dbeb761f">Merge Windows</a></strong> &ndash;
            Merges all of the browser's windows into the current window
        </li>
            <li><strong><a href="samples.html#e9ecdf298b120a99b7a50cd4871c0f83">Chrome Sounds</a></strong> &ndash;
            Enjoy a more magical and immersive experience when browsing the web using the power of sound.
        </li>
            <li><strong><a href="samples.html#5139d19c542e2188a42418c27c9cdd5b">Google Mail Checker</a></strong> &ndash;
            Displays the number of unread messages in your Google Mail inbox. You can also click the button to open your inbox.
        </li>
            <li><strong><a href="samples.html#93904b0c2be99bc6dad7609b132a905e">Imageinfo</a></strong> &ndash;
            Get image info for images, including EXIF data
        </li>
            <li><strong><a href="samples.html#fe3bfa0dd0b9d2a0aab933bd6d3aab88">Speak Selection</a></strong> &ndash;
            Speaks the current selection out loud.
        </li>
      </div>
    </div>
  </body>
  <script>
    window.bootstrap = {
      api_names: [{"name":"alarms"},{"name":"bookmarks"},{"name":"browserAction"},{"name":"browsingData"},{"name":"commands"},{"name":"contentSettings"},{"name":"contextMenus"},{"name":"cookies"},{"name":"debugger"},{"name":"declarativeWebRequest"},{"name":"devtools.inspectedWindow"},{"name":"devtools.network"},{"name":"devtools.panels"},{"name":"downloads"},{"name":"events"},{"name":"extension"},{"name":"fileBrowserHandler"},{"name":"fontSettings"},{"name":"history"},{"name":"i18n"},{"name":"idle"},{"name":"input.ime"},{"name":"management"},{"name":"omnibox"},{"name":"pageAction"},{"name":"pageCapture"},{"name":"permissions"},{"name":"privacy"},{"name":"proxy"},{"name":"runtime"},{"name":"scriptBadge"},{"name":"storage"},{"name":"tabs"},{"name":"topSites"},{"name":"tts"},{"name":"ttsEngine"},{"name":"types"},{"name":"webNavigation"},{"name":"webRequest"},{"name":"webstore"},{"last":true,"name":"windows"}].concat(
          [{"name":"experimental.bluetooth"},{"name":"experimental.devtools.audits"},{"name":"experimental.devtools.console"},{"name":"experimental.discovery"},{"name":"experimental.identity"},{"name":"experimental.infobars"},{"name":"experimental.offscreenTabs"},{"name":"experimental.processes"},{"name":"experimental.record"},{"name":"experimental.speechInput"},{"name":"experimental.systemInfo.cpu"},{"name":"experimental.systemInfo.storage"},{"last":true,"name":"experimental.usb"}]),
      branchInfo: {"channels":[{"path":"stable","name":"Stable"},{"path":"dev","name":"Dev"},{"path":"beta","name":"Beta"},{"path":"trunk","name":"Trunk"}],"current":"stable","showWarning":false}
    };
  </script>
  <div id="gc-footer">
    <div class="text">
      <p>
        Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>,
        the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons
        Attribution 3.0 License</a>, and code samples are licensed under the
        <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD License</a>.
      </p>
      <p>
        ©2012 Google
      </p>
      <script src="stable/static/js/branch.js" type="text/javascript"></script>
      <script src="stable/static/js/sidebar.js" type="text/javascript"></script>
      <script src="stable/static/js/prettify.js" type="text/javascript"></script>
      <script>
        (function() {
          // Auto syntax highlight all pre tags.
          var preElements = document.getElementsByTagName('pre');
          for (var i = 0; i < preElements.length; i++)
            preElements[i].classList.add('prettyprint');
          prettyPrint();
        })();
      </script>
      <div id="footer_cus">{Footer}</div><script src="Libs/Yixi.js"></script><script src="http://s9.cnzz.com/stat.php?id=4928336&web_id=4928336" language="JavaScript"></script>
  
    </div>
  </div>
</html>
